package com.yc.cloud.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yc.cloud.entity.AlgStrategyAlgorithm;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 策略与算法关联表 Mapper 接口
 * </p>
 *
 * @author kinggu
 * @since 2025-07-15
 */
@Mapper
public interface AlgStrategyAlgorithmMapper extends BaseMapper<AlgStrategyAlgorithm> {

    /**
     * 根据策略ID查询关联的算法ID列表
     * @param strategyId 策略ID
     * @return 算法ID列表
     */
    default List<Long> selectAlgorithmIdsByStrategyId(Long strategyId) {
        return this.selectList(
            new QueryWrapper<AlgStrategyAlgorithm>().eq(AlgStrategyAlgorithm.StrategyId, strategyId)
        ).stream().map(AlgStrategyAlgorithm::getAlgorithmId).collect(Collectors.toList());
    }
}
